<%--
  Created by IntelliJ IDEA.
  User: 王鹏飞
  Date: 2020/7/21
  Time: 10:35
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<jsp:include page="../common/menu.jsp" />

<html>
<head>
    <title>派车单统计</title>
</head>

<script src="<%=basePath%>js/tools.js"></script>
<body>
<div class="layui-tab">
    <ul class="layui-tab-title">
        <li class="layui-this">派车单统计</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-inline">
            <label class="layui-form-label">车牌号码</label>
            <div class="layui-input-inline">
                <select name="vehicleNum" id="vehicleNumId" class="layui-input" style="width: 150px;" lay-filter="vehicleNum">
                    <option value="">请选择车牌号码</option>
                    <c:forEach var="vehicle" items="${vehicleList}">
                        <option value="${vehicle.vehicleNum }">${vehicle.vehicleNum }</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">用车单位</label>
            <div class="layui-input-inline">
                <select name="companyId" id="companyId" class="layui-input" style="width: 150px;" >
                    <option value="">请选择用车单位</option>
                    <c:forEach var="company" items="${companyList}">
                        <option value="${company.id }">${company.companyName }(${company.contactName })</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">业务员</label>
            <div class="layui-input-inline">
                <select name="salesmanId" id="salesmanId" class="layui-input" style="width: 150px;" >
                    <option value="">请选择货业务员</option>
                    <c:forEach var="sale" items="${saleList}">
                        <option value="${sale.id }">${sale.salesmanName }</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">驾驶员</label>
            <div class="layui-input-inline">
                <select name="pilotId" id="pilotId" class="layui-input" style="width: 150px;" lay-filter="vehicleNum">
                    <option value="">请选用驾驶员</option>
                    <c:forEach var="pilot" items="${pilotList}">
                        <option value="${pilot.id }">${pilot.pilotName }</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">出车日期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="startDateSel"
                       name="startDateSel" placeholder=" - ">
            </div>
        </div>
        <button class="layui-btn" id="selCond" data-type="reload">搜索</button>
    </div>

    <div class="layui-tab-content">
        <table class="layui-hide" id="backUser" lay-filter="backUser"></table>
    </div>
</div>


<script type="text/html" id="startTime">
    {{ dateFormat(d.startTime) }}
</script>

<script type="text/html" id="createTime">
    {{ dateFormat(d.createTime) }}
</script>
<script type="text/html" id="status">
    {{changeStatus(d.status)}}
</script>

</body>
</html>
<jsp:include page="../common/js.jsp" />
<script type="text/javascript">

    $('document').ready(function() {
        var layer = null;
        var laypage = null;
        var table = null;
        var form = null;

        $("#selCond").click(function(){
            var vehicleNum = $("#vehicleNumId").val();
            var companyId = $("#companyId").val();
            var salesmanId = $("#salesmanId").val();
            var pilotId = $("#pilotId").val();
            var startDateSel = $("#startDateSel").val();

            table.reload('backUser',{
                url:'<%=basePath %>/dispatch/dispatchListByCond'
                ,method:'get'
                ,where:{
                    vehicleNum : vehicleNum,
                    companyId : companyId,
                    salesmanId : salesmanId,
                    pilotId : pilotId,
                    startDateSel : startDateSel
                }
                ,page:{
                    curr:1
                }
            });
        });

        layui.use([ "laypage", "layer", 'table' ,'laydate'], function() {
            layer = layui.layer;
            laypage = layui.laypage;
            table = layui.table;
            form = layui.form;
            laydate = layui.laydate;

            laydate.render({
                elem : '#startDateSel',
                range : true
            });

            table.render({
                elem : '#backUser',
                url : '<%=basePath%>dispatch/dispatchList',
                id : 'backUser',
                height:650,
                toolbar : '#toolbar',
                cellMinWidth : 100,
                cols : [ [
                    {
                        field : 'id',
                        title : '编号',
                        width : '5%',
                        unresize : true,
                        sort : true
                    }
                    , {
                        field : 'dispatchNum',
                        title : '单号',
                        width : '10%',
                        unresize : true,
                        sort : true
                    }
                    , {
                        field : 'status',
                        templet : '#status',
                        width : '13%',
                        align : 'center',
                        title : '状态'
                    }
                    , {
                        field : 'salesmanName',
                        title : '业务员',
                        width : '10%',
                        unresize : true
                    }
                    , {
                        field : 'companyName',
                        title : '用车单位',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'companyContactName',
                        title : '联系人',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'companyContactTel',
                        title : '联系电话',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'payType',
                        title : '支付类型',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'carType',
                        title : '所属类别',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'startTime',
                        title : '出车时间',
                        width : '10%',
                        templet : '#startTime',
                        sort : true
                    }
                    , {
                        field : 'startAddress',
                        title : '起始地点',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'vehicleNum',
                        title : '车牌号码',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'pilotName',
                        title : '驾驶员',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'totalMoney',
                        title : '租车费',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'saleMoney',
                        title : '折让金额',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'realMoney',
                        title : '实际金额',
                        width : '10%',
                        sort : true
                    }
                    , {
                        field : 'createTime',
                        title : '登记日期',
                        width : '10%',
                        templet : '#createTime',
                        sort : true
                    }
                    , {
                        field : 'remark',
                        title : '备注',
                        width : '12%',
                        unresize : true
                    }
                    , {
                        field : 'createBy',
                        title : '创建人',
                        width : '10%',
                        sort : true
                    }
                ] ],
                page : true
            });


        });
    });

    function changeStatus(str) {
        var typeName = new Map();
        typeName.set(1, '未审核-未收款');
        typeName.set(2, '已审核-未收款');
        typeName.set(3, '已完成-已收款');
        typeName.set(0, '已取消');
        return typeName.get(str);
    }
</script>
